#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;

bool judge(string s, char c)
{
    int n = s.size();
    for (int i = 0; i < n; i++)
        if (i < n - 1 && s[i] != c)
        {
            s[i] = c;
            s[i + 1] = (s[i + 1] - '0' + 1) % 2 + '0';
        }

    return s[n - 1] == c;
}

int main()
{
    string s;
    int q;
    cin >> q;
    while (q--)
    {
        cin >> s;
        auto res = judge(s, '0') || judge(s, '1');
        if (res)
            cout << "Yes" << endl;
        else    cout << "No" << endl;
    }
    return 0;
}